package com.czxy.service;

import com.czxy.dao.CustomerMapper;
import com.czxy.domain.Customer;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;

import javax.annotation.Resource;
import java.util.List;

@Service
@Transactional
public class CustomerServiceImpl implements CustomerService{
    @Resource
    private CustomerMapper customerMapper;

    @Override
    public List<Customer> findAll() {
        return customerMapper.findAll();
    }

    @Override
    public void insert(Customer customer) {
        customerMapper.insert(customer);
    }

    @Override
    public void delete(Customer customer) {

        customerMapper.deleteByPrimaryKey(customer);
    }

    @Override
    public boolean update(Customer customer) {


        Example example =new Example(Customer.class);

        Example.Criteria ct = example.createCriteria();


        ct.andEqualTo("custName",customer.getCustName());

        ct.andNotEqualTo("custId",customer.getCustId());


        List<Customer> list = customerMapper.selectByExample(example);





        return false;
    }

    @Override
    public Customer findById(Customer customer) {
        return null;
    }
}
